#include "DiamondData.h"
#include <QtCore/QSharedMemory>

int main()
{
  try {
    DiamondDataRow::register_dyntype();
    ifstream in("diamonds-dataset/4c.dat");
    //ifstream in("./4c.dat");
    vector<DiamondDataRow> drs;
    load_DiamonDataRow_file(in, &drs);
    cerr << "loaded " << drs.size() << " rows" << endl;

    QSharedMemory* m = new QSharedMemory("diamonds");
    m->create(1024 * 1024);
    void* m_data = m->data();
    DiamondDataRow* m_ptr = (DiamondDataRow*)m_data;
    for (size_t i = 0; i < drs.size(); i++) {
      new (m_ptr) DiamondDataRow(drs[i]);
      m_ptr += 1;
    }

  } catch (Error& e) {
    cerr << "Error caught: " << e.msg() << endl;
  }
}
